<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Node (computer science)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Node_(computer_science)"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Node_computer_science rootpage-Node_computer_science skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Node (computer science)</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p>A <b>node</b> is a basic unit of a <a href="Data_structure" title="Data structure">data structure</a>, such as a <a href="Linked_list" title="Linked list">linked list</a> or <a href="Tree_(data_structure)" class="mw-redirect" title="Tree (data structure)">tree</a> data structure. Nodes contain <a href="Data" title="Data">data</a> and also may link to other nodes. Links between nodes are often implemented by <a href="Pointer_(computer_programming)" title="Pointer (computer programming)">pointers</a>.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Nodes_and_trees">Nodes and trees</h2></div>
<p>Nodes are often arranged into tree structures. A node represents the information contained in a single data structure. These nodes may contain a value or condition, or possibly serve as another independent data structure. Nodes are represented by a single parent node. The highest point on a tree structure is called a root node, which does not have a parent node, but serves as the parent or 'grandparent' of all of the nodes below it in the tree. The height of a node is determined by the total number of edges on the path from that node to the furthest leaf node, and the height of the tree is equal to the height of the root node.<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> Node depth is determined by the distance between that particular node and the root node. The root node is said to have a depth of zero.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> Data can be discovered along these network paths.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup>
An IP address uses this kind of system of nodes to define its location in a network.
</p>
<div class="mw-heading mw-heading3"><h3 id="Definitions">Definitions</h3></div>
<ul><li><b>Child</b>: A child node is a node extending from another node. For example, a computer with internet access could be considered a child node of a node representing the internet. The inverse relationship is that of a <b>parent node</b>. If node <i>C</i> is a child of node <i>A</i>, then <i>A</i> is the parent node of <i>C</i>.</li>
<li><b>Degree</b>: the degree of a node is the number of children of the node.</li>
<li><b>Depth</b>: the depth of node <i>A</i> is the length of the path from <i>A</i> to the root node. The root node is said to have depth 0.</li>
<li><b>Edge</b>: the connection between nodes.</li>
<li><b>Forest</b>: a set of trees.</li>
<li><b>Height</b>: the height of node <i>A</i> is the length of the longest path through children to a leaf node.</li>
<li><b>Internal node</b>: a node with at least one child.</li>
<li><b>Leaf node</b>: a node with no children.</li>
<li><b>Root node</b>: a node distinguished from the rest of the tree nodes. Usually, it is depicted as the highest node of the tree.</li>
<li><b>Sibling nodes</b>: these are nodes connected to the same parent node.</li></ul>
<div class="mw-heading mw-heading2"><h2 id="Markup_languages">Markup languages</h2></div>
<p>Another common use of node trees is in <a href="Web_development" title="Web development">web development</a>. In programming, <a href="XML" title="XML">XML</a> is used to communicate information between computer programmers and computers alike. For this reason XML is used to create common <a href="Communication_protocol" title="Communication protocol">communication protocols</a> used in <a href="Office_productivity_software" class="mw-redirect" title="Office productivity software">office productivity software</a>, and serves as the base for the development of modern web <a href="Markup_language" title="Markup language">markup languages</a> like <a href="XHTML" title="XHTML">XHTML</a>. Though similar in how it is approached by a programmer, <a href="HTML" title="HTML">HTML</a> and <a href="CSS" title="CSS">CSS</a> is typically the language used to develop website text and design. While XML, HTML and XHTML provide the language and expression, the <a href="Document_Object_Model" title="Document Object Model">DOM</a> serves as a translator.<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Node_type">Node type</h3></div>
<p>Different types of nodes in a tree are represented by specific interfaces. In other words, the node type is defined by how it communicates with other nodes. Each node has a node type property, which specifies the type of node, such as sibling or leaf.
For example, if the node type property is the constant properties for a node, this property specifies the type of the node. So if a node type property is the constant node ELEMENT_NODE, one can know that this node object is an object Element. This object uses the Element interface to define all the methods and properties of that particular node.
</p><p>Different W3C <a href="World_Wide_Web_Consortium" title="World Wide Web Consortium">World Wide Web Consortium</a> node types and descriptions:
</p>
<ul><li><b>Document</b> represents the entire document (the root-node of the DOM tree)</li>
<li><b>DocumentFragment</b> represents a "lightweight" Document object, which can hold a portion of a document</li>
<li><b>DocumentType</b> provides an interface to the entities defined for the document</li>
<li><b>ProcessingInstruction</b> represents a processing instruction</li>
<li><b>EntityReference</b> represents an entity reference</li>
<li><b>Element</b> represents an element</li>
<li><b>Attr</b> represents an attribute</li>
<li><b>Text</b> represents textual content in an element or attribute</li>
<li><b>CDATASection</b> represents a <a href="CDATA" title="CDATA">CDATA</a> section in a document (text that will NOT be parsed by a parser)</li>
<li><b>Comment</b> represents a comment</li>
<li><b>Entity</b> represents an entity</li>
<li><b>Notation</b> represents a notation declared in the DTD</li></ul>
<table class="wikitable">
<tbody><tr>
<th>NodeType</th>
<th>Named constant
</th></tr>
<tr>
<td>1</td>
<td>ELEMENT_NODE
</td></tr>
<tr>
<td>2</td>
<td>ATTRIBUTE_NODE
</td></tr>
<tr>
<td>3</td>
<td>TEXT_NODE
</td></tr>
<tr>
<td>4</td>
<td>CDATA_SECTION_NODE
</td></tr>
<tr>
<td>5</td>
<td>ENTITY_REFERENCE_NODE
</td></tr>
<tr>
<td>6</td>
<td>ENTITY_NODE
</td></tr>
<tr>
<td>7</td>
<td>PROCESSING_INSTRUCTION_NODE
</td></tr>
<tr>
<td>8</td>
<td>COMMENT_NODE
</td></tr>
<tr>
<td>9</td>
<td>DOCUMENT_NODE
</td></tr>
<tr>
<td>10</td>
<td>DOCUMENT_TYPE_NODE
</td></tr>
<tr>
<td>11</td>
<td>DOCUMENT_FRAGMENT_NODE
</td></tr>
<tr>
<td>12</td>
<td>NOTATION_NODE
</td></tr></tbody></table>
<div class="mw-heading mw-heading3"><h3 id="Node_object">Node object</h3></div>
<p>A node object is represented by a single node in a tree. It can be an element node, attribute node, text node, or any type that is described in section "node type". All objects can inherit properties and methods for dealing with parent and child nodes, but not all of the objects have parent or child nodes. For example, with text nodes that cannot have child nodes, trying to add child nodes results in a <a href="Document_Object_Model" title="Document Object Model">DOM</a> error.
</p><p>Objects in the DOM tree may be addressed and manipulated by using methods on the objects. The public interface of a DOM is specified in its <a href="Application_programming_interface" class="mw-redirect" title="Application programming interface">application programming interface</a> (API). The history of the Document Object Model is intertwined with the history of the "<a href="Browser_wars" title="Browser wars">browser wars</a>" of the late 1990s between <a href="Netscape_Navigator" title="Netscape Navigator">Netscape Navigator</a> and <a href="Microsoft_Internet_Explorer" class="mw-redirect" title="Microsoft Internet Explorer">Microsoft Internet Explorer</a>, as well as with that of <a href="JavaScript" title="JavaScript">JavaScript</a> and <a href="JScript" title="JScript">JScript</a>, the first <a href="Scripting_language" title="Scripting language">scripting languages</a> to be widely implemented in the <a href="Browser_engine" title="Browser engine">layout engines</a> of <a href="Web_browser" title="Web browser">web browsers</a>.
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Vertex_(graph_theory)" title="Vertex (graph theory)">Vertex (graph theory)</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://xlinux.nist.gov/dads//HTML/tree.html">"tree (data structure)"</a>. <a href="National_Institute_of_Standards_and_Technology" title="National Institute of Standards and Technology">National Institute of Standards and Technology</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20141124223717/http://xlinux.nist.gov/dads/HTML/tree.html">Archived</a> from the original on 2014-11-24.</cite></span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><cite id="CITEREFTeukolsky2013" class="citation book cs1">Teukolsky, Roselyn (2013). <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/apcomputerscienc0006teuk"><i>Barron's AP Computer Science A</i></a></span>. <a href="Barron's_Educational_Series" class="mw-redirect" title="Barron's Educational Series">Barron's</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-1-4380-0152-4</bdi>.</cite></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.eecs.berkeley.edu/~bh/ssch18/trees.html">"Simply Scheme: Introducing Computer Science ch 18: Trees"</a>. College Of Engineering, <a href="University_of_California%2C_Berkeley" title="University of California, Berkeley">University of California, Berkeley</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20131222183836/http://www.eecs.berkeley.edu/~bh/ssch18/trees.html">Archived</a> from the original on 2013-12-22.</cite></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20140611052725/https://www.w3schools.com/dom/dom_intro.asp">"XML DOM Introduction"</a>. <a href="W3Schools" title="W3Schools">W3Schools</a>. Archived from <a rel="nofollow" class="external text" href="https://www.w3schools.com/dom/dom_intro.asp">the original</a> on 2014-06-11<span class="reference-accessdate">. Retrieved <span class="nowrap">2018-04-07</span></span>.</cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><a rel="nofollow" class="external text" href="http://www.community-of-knowledge.de/beitrag/data-trees-as-a-means-of-presenting-complex-data-analysis/">Data Trees as a Means of Presenting Complex Data Analysis</a> by Sally Knipe</li>
<li><a rel="nofollow" class="external text" href="http://tree.phi-sci.com">STL-like C++ tree class</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20201126210313/http://tree.phi-sci.com/">Archived</a> 2020-11-26 at the <a href="Wayback_Machine" title="Wayback Machine">Wayback Machine</a></li>
<li><a rel="nofollow" class="external text" href="https://web.archive.org/web/20180306223544/http://ideainfo.8m.com/">Description of tree data structures from ideainfo.8m.com</a></li>
<li><a rel="nofollow" class="external text" href="http://wormweb.org/celllineage">WormWeb.org: Interactive Visualization of the <i>C. elegans</i> Cell Tree</a> - Visualize the entire cell lineage tree of the nematode <i>C. elegans</i> (javascript)</li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2024-12-01" href="https://en.wikipedia.org/wiki/?title=Node_(computer_science)&oldid=1260538817">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>